# - Define "check_machine" macro to determine the type of machine
# Once invoked, this will define
#  mach - 32 or 64
#  os   - "Mac OS X" or "Linux"

macro(check_machine)
    message(STATUS "")
    message(STATUS "check_machine results:")
    execute_process(COMMAND which uname OUTPUT_VARIABLE exist OUTPUT_STRIP_TRAILING_WHITESPACE)
    if(exist STREQUAL "")
        message(FATAL_ERROR "Can not find \"uname\" to determine machine type")
    else(exist STREQUAL "")
        execute_process(COMMAND uname -m OUTPUT_VARIABLE mach OUTPUT_STRIP_TRAILING_WHITESPACE)
        if(mach MATCHES "i386")
            message(STATUS "--> Machine is 32-bit")
            set(mach "32")
        else(mach MATCHES "i386")
            message(STATUS "--> Machine is 64-bit")
            set(mach "64")
        endif(mach MATCHES "i386")
        execute_process(COMMAND uname -s OUTPUT_VARIABLE os OUTPUT_STRIP_TRAILING_WHITESPACE)
        if(os MATCHES "Darwin")
            message(STATUS "--> Operating System is Mac OS X")
            set(os "Mac OS X")
        elseif(os MATCHES "Linux")
            message(STATUS "--> Operating System is Linux")
            set(os "Linux")
        endif(os MATCHES "Darwin")
    endif(exist STREQUAL "")
endmacro(check_machine)
